home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 4864 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  1.9 KB

  1. Path: news.otol.fi!rhea!tkes
  2. From: tkes@rhea.otol.fi (Timo Sakari)
  3. Newsgroups: comp.lang.c,comp.lang.c++
  4. Subject: New printf - like function, is it possible?
  5. Date: 1 Feb 1996 12:18:50 GMT
  6. Organization: Oulu Institute of Technology, Finland
  7. Message-ID: <4eqb3a$2r5@pan.otol.fi>
  8. NNTP-Posting-Host: rhea-atm.otol.fi
  9. X-Newsreader: TIN [version 1.2 PL0]
  10.  
  11.  
  12. Hi!
  13.  
  14. Do you C-gurus have any solutions to this problem?
  15.  
  16. I am programming under MS Windows 3.1 (this is NOT an OS spesific 
  17. question!)and I would like to create
  18. some kind of modified print function, which syntax should be something
  19. like normal printf; because in Windows printf can't be used, everything
  20. printed to screen has to come through message boxes etc, and before 
  21. displaying anything, the string to displayed has to be formed. I have 
  22. created my own printing function, which wants parameters string and winID
  23. to know where to put that string, something like this: 
  24.  
  25. sprintf(printStr, "some sfuff, variables %d, %f, etc", var1, var2);
  26. PrintToWin(DEBUG_WIN_1, printStr);
  27.  
  28. However, I want to write a "better" printing function, where string to be
  29. formed doesn't need to be formatted first, it can be displayed and formed
  30. at the same time in the same syntax like printf, something like these:
  31.  
  32. PrintToWin(DEBUG_WIN_1, "some stuff etc, %d, %f, %s, var1, var2, str1);
  33. PrintToWin(OTHER_WIN, "anything that printf accepts");
  34.  
  35. So I want to print almost anything with this function without having
  36. to write many functions to different argument types/number of arguments.
  37. This should be possible in C++ (is it?), but is it possible in C ?
  38. Can this be achieved by using void pointers and macros etc., or should
  39. I give up and don't waste my time on this?
  40.  
  41. Any help would be greatly appreciated. Thanks.
  42.  
  43.  
  44.  
  45. --
  46.    Timo Sakari          phone: (981) 5306 070 
  47.    Haapanatie 2 D 408   email: tkes@rhea.otol.fi
  48.    90150 OULU           WWW: http://www.otol.fi/~tkes/
  49.    FINLAND
  50.